﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

using System.Globalization;
using System.Threading;

namespace IDE__week2
{
    public partial class Form1 : Form
    {
        Form2 form2 = new Form2();
        Icon currentIcon;
        string currentLang = "en";
        public Form1()
        {
            // Sets the UI culture to German (Germany).
            Thread.CurrentThread.CurrentUICulture = new CultureInfo(currentLang);
            InitializeComponent();
            form2.Icon = Properties.Resources.Icon2;
            currentIcon = Icon;
        }

        private void ChangeLanguage(string lang)
        {
            foreach (Control c in this.Controls)
            {
                ComponentResourceManager resources =
                      new ComponentResourceManager(typeof(Form1));
                resources.ApplyResources(c, c.Name, new CultureInfo(lang));
            }
            currentLang = lang;
        }


        private void button2_Click(object sender, EventArgs e)
        {
            if(!form2.Visible)
                form2.Show();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Icon = Properties.Resources.Icon2;
        }

        private void button3_Click(object sender, EventArgs e)
        {
            Icon = currentIcon;
        }
        int i = 0;
        private void button5_Click(object sender, EventArgs e)
        {
            if (currentLang == "en")
                if (i++ % 2 == 0)
                    ChangeLanguage("de");
                else
                    ChangeLanguage("nl");
            else
                ChangeLanguage("en");
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void button4_Click(object sender, EventArgs e)
        {
            int[] numbers = new int[10];
            Class1.MakeRandomNumber(numbers);
            label1.Text = numbers[0] + ", " + numbers[1] + ", " + numbers[2];
        }
    }
}
